var myApp = {
    getDom: (function () {
        var container = document.querySelector(".container");
        var btn = document.querySelector("button");

        return {
            container,
            btn
        }
    })(),

    methods: {
        add() {
            var container = myApp.getDom?.container;
            var btn = myApp.getDom?.btn;
            var key = null;

            btn.onclick = () => {
                if (!key) {
                    container.style.width = 200 + "px";
                    key = true;
                }else if (key) {
                    container.style.width = 0;
                    key = null;
                }
            }
        }
    }
}

myApp.methods.add();